package com.javabase.y2022.m04.day0426.v1;

/**
 * @descriptions:
 * @author: Tom
 * @date: 2022/4/26 下午 05:23
 * @version: 1.0
 */
public class Solution {
    public static void main(String[] args) {
        Solution s = new Solution();
        int[][] arr = new int[][]{{1,2},{3,4}};
        System.out.println(s.projectionArea(arr));;
    }
    public int projectionArea(int[][] grid) {
        int N = grid.length;
        int sum = 0;
        for (int i = 0; i < N; i++) {
            int valueX = Integer.MIN_VALUE;
            int valueY = Integer.MIN_VALUE;
            for (int j = 0; j < N; j++) {
                if(grid[i][j] != 0){
                    sum += 1;
                }
                valueX = Math.max(valueX, grid[i][j]);
                valueY = Math.max(valueY, grid[j][i]);
            }
            sum += valueX;
            sum += valueY;
        }
        return sum;
    }
}
